package com.cmol.peopledetectapp.admin;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cmol.peopledetectapp.R;

import java.util.List;

/**
 * ListView 辅助类，用户列表
 *
 * @author 张瀚文
 */
public class MyAdapterUser extends BaseAdapter {

    private List<BeanUser> data;
    private Context context;

    public MyAdapterUser(List<BeanUser> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_user, parent, false);
        }

        TextView textView = convertView.findViewById(R.id.UserText);
        textView.setText(data.get(position).getName());

        return convertView;
    }
}